import Vue from 'vue'
import VueRouter from 'vue-router'

const Index = () => import('../views/Index');
const Detail = () => import('../views/Detail');
const Chart = () => import('../views/Chart');
Vue.use(VueRouter)

const routes = [{
    path: '',
    redirect: '/index'
  },
  {
    path: '/index',
    component: Index
  },
  {
    path: '/detail',
    component: Detail
  },
  {
    path: '/chart',
    component: Chart
  },
]

const router = new VueRouter({
  routes: routes,
  base: process.env.BASE_URL,
  routes
})


//解决路由冗余问题
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router